<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" v-model="user.username" placeholder="请输入用户名">
  <input type="password" v-model="user.password" placeholder="请输入用密码">
  <input type="button" value="登录" @click="login()">
</div>

<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script>
  let v = new Vue({
    el:"div",
    data:{
      user:{
        username:"",
        password:"",
      }
    },
    methods:{
      login(){
        axios.post("/login",v.user).then(function (response){
          if (response.data==1){
            alert("登陆成功!")
            location.href="/";
            return;
          }else if (response.data==2){
            alert("您输入的密码有误!")
            v.user.username="";
            v.user.password="";
            return;
          }
          alert("该用户不存在!")
          v.user.username="";
          v.user.password="";

        })
      }
    }
  })
</script>
</body>
</html>